#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<math.h>
int main() {
	for (int i = 1; i <= 99999; i++) {
		int ge = i % 10;
		int shi = i % 100 / 10;
		int bai = i % 1000 / 100;
		int qian = i /1000%10;
		int wan = i /10000;
		if (i >= 100 && i < 1000) {
			int sum = pow(ge, 3) + pow(shi, 3) + pow(bai, 3) + pow(qian, 3) + pow(wan, 3);
			if (sum == i) {
				printf("%d ", i);
			}
		}
		if (i >= 1000 && i < 10000) {
			int sum = pow(ge, 4) + pow(shi, 4) + pow(bai, 4) + pow(qian, 4) + pow(wan, 4);
			if (sum == i) {
				printf("%d ", i);
			}
		}
		if (i >= 10000 && i < 100000) {
			int sum = pow(ge, 5) + pow(shi, 5) + pow(bai, 5) + pow(qian, 5) + pow(wan, 5);
			if (sum == i) {
				printf("%d ", i);
			}
		}
	}
	return 0;
}